<?php

namespace app\api\controller;

use app\admin\model\Policy;
use app\admin\model\Type;
use app\admin\model\Typelist;
use app\common\controller\Api;
use app\admin\model\Order;


/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 用户协议与隐私政策
     * Summary of policy
     * @param mixed $status
     * @return void
     */
    public function policy($status = 0)
    {
        $list = Policy::where(['status' => $status])->find();
        $this->success('suc',$list);
    }
    /**
     * 服务类型
     * Summary of type
     * @return void
     */
    public function type()
    {
        $list = Type::select();
        $this->success('suc',$list);
    }
    /**
     * 服务类型子类
     * Summary of typeList
     * @return void
     */
    public function typeList()
    {
        $list = Type::select();
        foreach($list as $key => $value) {
            $typeList = Typelist::where(['type_id' => $value['id']])->select();
            $list[$key]['detail'] = $typeList;
        }
        $this->success('suc',$list);
    }
    /**
     * 
     * Summary of order
     * @return void
     */
    public function order($page = 1){
        $list = Order::where(['status' => 0])->order('id desc')->paginate(20,false,['page' => $page]);
        $this->success('suc',$list);
    }
    /**
     * 订单详情
     * Summary of orderDetail
     * @param mixed $id
     * @return void
     */
    public function orderDetail($id = '')
    {
        if(!$id) $this->error('fail');
        $orderDetail = Order::find($id);
        $this->success('suc',$orderDetail);
    }
}
